<?php

// 指定session 名字
session_name('JSESSIONID');
session_start();

//引入系统参数
require_once("configure.php");
// 权限参数
require_once("power.php");

// 引入基础函数库
$libArray = ['array', 'basic', 'const', 'file', 'img', 'network', 'string', 'validate', 'db'];
foreach ($libArray as $path) {
	require_once serverRoot . "core/$path.php";
}
// 引入语言包文件
$locales = match (lang) {
    'TC'    => 'zh_HK.php',
    'EN'    => 'en.php',
    default => 'zh_CN.php',
};
$GLOBALS['languagePack'] = require_once serverRoot . 'lang/' . $locales;

//检测是否启用开发模式
error_reporting(E_ALL);
if (debug === true) {
	ini_set('display_errors', 'On');
} else {
	ini_set('display_errors', 'Off');
}

/*初始化数据库*/
try {
	$con = mysqli_connect($conf['serverName'], $conf['userName'], $conf['password'], $conf['databaseName']);
	mysqli_query($con, "set names 'utf8mb4'");
} catch (Throwable $th) {
	exit("could not connect: " . mysqli_connect_error());
}
// 调整格林威治时间为北京时间
date_default_timezone_set('Etc/GMT-8');

//获取当前日期时间
$time = date("Y-m-d H:i:s");
$date = date("Y-m-d");
/*处理所有GET和POST参数*/
$post  = $get = [];
$_POST = isset($_POST['serialize_json']) ? (array)json_decode($_POST['serialize_json'], true) : $_POST;
foreach ($_POST as $key => $value) {
	$post[$key] = formSubArray($value);
}
foreach ($_GET as $key => $value) {
	$get[$key] = formSubArray($value);
}
